package com.ly.web.controller.erp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.BuyBidEntity;
import com.ly.heart.service.IBuyBidService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

/**
 * 购买标书记录Controller
 *
 * @author cxl
 * @date 2024-05-14
 */
@Api(value = "BuyBid", tags = "购买标书记录")
@RestController
@RequestMapping("/heart/BuyBid")
public class BuyBidController extends BaseController
{
    @Autowired
    private IBuyBidService buyBidService;

    /**
     * 查询购买标书记录列表
     */
//    @PreAuthorize("@ss.hasPermi('heart:BuyBid:list')")
//    @GetMapping("/list")
//    @ApiOperation("查询购买标书记录列表")
//    public TableDataInfo list(BuyBidEntity buyBidEntity)
//    {
//        startPage();
//        List<BuyBidEntity> list = buyBidService.selectBuyBidEntityList(buyBidEntity);
//        return getDataTable(list);
//    }

    /**
     * 导出购买标书记录列表
     */
    @PreAuthorize("@ss.hasPermi('heart:BuyBid:export')")
    @Log(title = "购买标书记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出购买标书记录列表")
    public void export(HttpServletResponse response, BuyBidEntity buyBidEntity)
    {
        List<BuyBidEntity> list = buyBidService.selectBuyBidEntityList(buyBidEntity);
        ExcelUtil<BuyBidEntity> util = new ExcelUtil<BuyBidEntity>(BuyBidEntity.class);
        util.exportExcel(list, "购买标书记录数据");
    }

    @PreAuthorize("@ss.hasPermi('heart:BuyBid:list')")
    @PostMapping("/list")
    @ApiOperation("查询购买标书记录列表")
    public AjaxResult selectBuyBidVoList(@RequestBody BuyBidEntity buyBidEntity)
    {
        return buyBidService.selectBuyBidVoList(buyBidEntity);
    }

    /**
     * 获取购买标书记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:BuyBid:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取购买标书记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
//        return AjaxResult.success(buyBidService.selectBuyBidEntityById(id));
        return AjaxResult.success(buyBidService.selectBuyBidVoById(id));
    }

    /**
     * 新增购买标书记录
     */
    @PreAuthorize("@ss.hasPermi('heart:BuyBid:add')")
    @Log(title = "购买标书记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增购买标书记录")
    public AjaxResult add(@RequestBody BuyBidEntity buyBidEntity)
    {
        return toAjax(buyBidService.insertBuyBidEntity(buyBidEntity));
    }

    /**
     * 修改购买标书记录
     */
    @PreAuthorize("@ss.hasPermi('heart:BuyBid:edit')")
    @Log(title = "购买标书记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改购买标书记录")
    public AjaxResult edit(@RequestBody BuyBidEntity buyBidEntity)
    {
        return toAjax(buyBidService.updateBuyBidEntity(buyBidEntity));
    }

    /**
     * 删除购买标书记录
     */
    @PreAuthorize("@ss.hasPermi('heart:BuyBid:remove')")
    @Log(title = "购买标书记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除购买标书记录")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buyBidService.deleteBuyBidEntityByIds(ids));
    }
}
